﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TransactionTemplateSelector.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the <seealso cref="AccountTemplateSelector"/> type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Client.Modules.Core.Transaction
{
    using System.Windows;
    using System.Windows.Controls;

    using Hisaab.Client.Model;

    /// <summary>
    /// Defines the <seealso cref="TransactionTemplateSelector"/> type.
    /// </summary>
    public class TransactionTemplateSelector : DataTemplateSelector
    {
        /// <summary>
        /// When overridden in a derived class, returns a <see cref="T:System.Windows.DataTemplate"/> based on custom logic.
        /// </summary>
        /// <param name="item">The data object for which to select the template.</param>
        /// <param name="container">The data-bound object.</param>
        /// <returns>
        /// Returns a <see cref="T:System.Windows.DataTemplate"/> or null. The default value is null.
        /// </returns>
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var presenter = container as ContentPresenter;
            if (item is Transaction)
            {
                return presenter.FindResource("transactionView") as DataTemplate;
            }

            return base.SelectTemplate(item, container);
        }
    }
}